package drds.server.sqlparser.visitor;

import java.util.ArrayList;
import java.util.List;

import drds.server.sqlparser.sqlobject.expression.InList;
import drds.server.sqlparser.sqlobject.expression.Variable;
import drds.server.sqlparser.sqlobject.expression.binary.BinaryExpression;
import drds.server.sqlparser.sqlobject.expression.data_type.Null;
import drds.server.sqlparser.sqlobject.expression.data_type.Text;
import drds.server.sqlparser.sqlobject.expression.data_type.number.Decimal;
import drds.server.sqlparser.sqlobject.expression.data_type.number.Int;
import drds.server.sqlparser.sqlobject.expression.name.Identifier;

/**
 * 
 * @author 曹正辉<330937205@qq.com>
 * 
 */
public class EvalVisitorImpl extends VisitorAdapter implements EvalVisitor {

	private List<Object> parameters = new ArrayList<Object>();

	private int variantIndex = -1;

	private boolean markVariantIndex = true;

	public EvalVisitorImpl() {
		this(new ArrayList<Object>(1));
	}

	public EvalVisitorImpl(List<Object> parameters) {
		this.parameters = parameters;
	}

	public List<Object> getParameterList() {
		return parameters;
	}

	public void setParameterList(List<Object> parameters) {
		this.parameters = parameters;
	}

	public boolean visit(Text x) {
		return EvalVisitorUtils.visit(this, x);
	}

	public int incAndGetVariantIndex() {
		return ++variantIndex;
	}

	public int getVariantIndex() {
		return variantIndex;
	}

	public boolean visit(Variable x) {
		return EvalVisitorUtils.visit(this, x);
	}

	public boolean visit(BinaryExpression x) {
		return EvalVisitorUtils.visit(this, x);
	}

	public boolean visit(Int x) {
		return EvalVisitorUtils.visit(this, x);
	}

	public boolean visit(Decimal x) {
		return EvalVisitorUtils.visit(this, x);
	}

	@Override
	public boolean visit(InList x) {
		return EvalVisitorUtils.visit(this, x);
	}

	@Override
	public boolean visit(Null x) {
		return EvalVisitorUtils.visit(this, x);
	}

	public boolean isMarkVariantIndex() {
		return markVariantIndex;
	}

	public void setMarkVariantIndex(boolean markVariantIndex) {
		this.markVariantIndex = markVariantIndex;
	}

	public boolean visit(Identifier x) {
		return EvalVisitorUtils.visit(this, x);
	}

}
